package android.slc.wrapper;

import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;

import java.util.Collections;
import java.util.List;

/**
 * @author slc
 * @date 2024/9/25
 **/
public abstract class BaseWrapper<T> {
    public static String TAG_SINGLE = "single";
    public static String TAG_LIST = "list";

    public void fill(T data) {
        if (data != null) {
            fillData(TAG_SINGLE, Collections.singletonList(data));
        }
    }

    public void fill(List<T> dataList) {
        if (CollectionUtil.isEmpty(dataList)) {
            return;
        }
        fillData(TAG_LIST, dataList);
    }

    public abstract void fillData(String tag, List<T> dataList);

    public boolean isSingleTag(String tag) {
        return StrUtil.equals(tag, TAG_SINGLE);
    }

    public boolean isListTag(String tag) {
        return StrUtil.equals(tag, TAG_LIST);
    }

}
